#include "mainwindow.h"
#include "./ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QObject::connect(&m_ollamaClient, &OllamaClient::responseReceived, [](const QString &response) {
            qDebug() << "Full Response:" << response;
        //ui->textBrowser->insertPlainText()
        });

        QObject::connect(&m_ollamaClient, &OllamaClient::streamDataReceived, [this](const QString &data) {
            qDebug() << "Stream Data:" << data;
            ui->textBrowser->insertPlainText(data);
        });

        QObject::connect(&m_ollamaClient, &OllamaClient::errorOccurred, [this](const QString &error) {
            ui->textBrowser->insertPlainText(error);
            qDebug() << "Error:" << error;
        });
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    ui->textBrowser->insertHtml("<br><hr/><br>");
    m_ollamaClient.askQuestion(ui->lineEdit->text());
}

